<template>
    <f7-page @page:init="initWithManagerView()" @page:reinit="reloadView()" data-page="manager">
        <f7-navbar title="管理"></f7-navbar>
        <div class="list-block" style="margin-top: 0px;">
            <ul v-for="item in goverUsers">
                <div v-if="prvilegeLevel == 1 || prvilegeLevel == 2">
                    <li v-if="item.Id == 0">
                        <a :href="`/manager/addPerson/${item.RegionId}/RegionName/${item.RegionName}`" class="item-link item-content">
                            <div class="item-inner">
                                <div class="item-title">{{item.RegionName}}</div>
                                <div class="item-after" style="color: red" >添加管理员</div>
                            </div>
                        </a>
                    </li>
                    <li v-else>
                        <a :href="`/manager/updatePerson/${item.Id}/Name/${item.Name}/Phoneno/${item.Phoneno}/RegionId/${item.RegionId}/RegionName/${item.RegionName}`" class="item-link item-content" >
                            <div class="item-inner">
                                <div class="item-title">{{item.RegionName}}</div>
                                <div class="item-after">{{item.Name}}  {{item.Phoneno}}</div>
                            </div>
                        </a>
                    </li>
                </div>
                <div v-else>
                    <li v-if="item.Authentication==1">
                        <a :href="`/manager/farmerAuth/${item.Id}`" class="item-link item-content">
                            <div class="item-inner">
                                <div class="item-title">{{item.Name}}</div>
                                <div class="item-after" style="color: red" >待认证</div>
                            </div>
                        </a>
                    </li>
                    <li v-if="item.Authentication==2">
                        <a :href="`/manager/authed/${item.Id}`" class="item-link item-content">
                            <div class="item-inner">
                                <div class="item-title">{{item.Name}}</div>
                                <div class="item-after">{{item.Phoneno}}</div>
                            </div>
                        </a>
                    </li>
                    <li v-if="item.Authentication==3">
                        <a :href="`/manager/authed/${item.Id}`" class="item-link item-content">
                            <div class="item-inner">
                                <div class="item-title">{{item.Name}}</div>
                                <div class="item-after" style="color: red">认证未通过</div>
                            </div>
                        </a>
                    </li>
                </div>
            </ul>
        </div>
    </f7-page>
</template>

<script>
    import data from '../../../src/data/index'
    import helper from '../../../src/common/helper'

    export default{
        data(){
           return{
               goverUsers:[],
               prvilegeLevel:''
           }
        },
        methods:{
            initWithManagerView(){
                this.prvilegeLevel = helper.localStorage('userMsg').PrvilegeLevel;
                this.requestViewData();
            },
            reloadView(){
                this.requestViewData();
            },
            requestViewData(){
                let that = this;
                data.gover.goverUser(function (data) {
                    that.goverUsers = data;
                })
            }
        }
    }
</script>